package com.chixing.day04_oop.account;

/**
 * 信用账户
 */
public class CreditAccount extends Account{
    public float creMaxOverdraw;
    public float creCredit;

    public float getCreMaxOverdraw() {
        return creMaxOverdraw;
    }

    public void setCreMaxOverdraw(float creMaxOverdraw) {
        this.creMaxOverdraw = creMaxOverdraw;
    }

    public float getCreCredit() {
        return creCredit;
    }

    public void setCreCredit(float creCredit) {
        this.creCredit = creCredit;
    }

    @Override
    public String toString() {
        return "CreditAccount{" +
                "creMaxOverdraw=" + creMaxOverdraw +
                ", creCredit=" + creCredit +
                '}';
    }

    public void overdraw(float n){
        if (super.accBalance>=n){
            super.accBalance -=n;
        }
        else{
            this.creCredit = n -super.accBalance + this.creCredit;
            super.accBalance = 0;
        }
    }
}
